<template>
    <div class="app-container">
      <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch"
               label-width="68px">
          <el-form-item label="出库单号" prop="nos">
            <el-input v-model="queryParams.nos" placeholder="请输入单据号"
                      clearable @keyup.enter.native="handleQuery"/>
          </el-form-item>
          <el-form-item label="产品编码" prop="code">
            <el-input v-model="queryParams.code" placeholder="请输入产品编码"
                      clearable @keyup.enter.native="handleQuery"/>
          </el-form-item>
          <el-form-item label="产品名称" prop="goodsName">
            <el-input v-model="queryParams.params['goodsName']" placeholder="请输入产品名称"
                      clearable @keyup.enter.native="handleQuery"/>
          </el-form-item>
          <el-form-item label="产品型号" prop="goodsModel">
            <el-input v-model="queryParams.params['goodsModel']" placeholder="请输入产品型号"
                      clearable @keyup.enter.native="handleQuery"/>
          </el-form-item>
          <el-form-item label="出库人" prop="rukuren">
            <el-input v-model="queryParams.params['rukuren']" placeholder="请输入出库人"
                      clearable @keyup.enter.native="handleQuery"/>
          </el-form-item>
          <el-form-item label="出入库日期">
        <el-date-picker v-model="dateRange"
                        style="display: flex;"
                        value-format="yyyy-MM-dd"
                        type="daterange"
                        range-separator="-"
                        start-placeholder="开始日期"
                        end-placeholder="结束日期"
        ></el-date-picker>
      </el-form-item>
        <el-form-item>
          <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
          <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
        </el-form-item>
      </el-form>

      <el-table border v-loading="loading" :data="dataList" @selection-change="handleSelectionChange" ref="table"
                :max-height="tableMaxHeight" @sort-change="handleSortChange">
        <el-table-column type="selection" width="55" align="center"/>
        <el-table-column sortable label="出库单号" align="center" prop="nos"/>
        <el-table-column  label="供应商" align="center" prop="supplierName"/>
        <el-table-column sortable label="产品编码" align="center" prop="code"/>
        <el-table-column  label="产品名称" align="center" prop="params.goodsName"/>
        <el-table-column  label="产品型号" align="center" prop="params.goodsModel"/>
        <el-table-column  label="产品数量" align="center" prop="daohuoCount"/>
        <el-table-column  label="重量" align="center" prop="dun"/>
        <el-table-column  label="单价" align="center" prop="goodsBuyPrice"/>
        <el-table-column  label="总价" align="center" prop="goodsBuyTotal"/>
        <el-table-column sortable label="出库日期" align="center" prop="rukudate">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.rukudate, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>>
        <el-table-column sortable label="出库人" align="center" prop="rukuren"/>
        <el-table-column sortable label="状态" align="center" prop="type">
          <template slot-scope="scope">
            <dict-tag :options="dict.type.churuku_type" :value="scope.row.type"/>
          </template>
        </el-table-column>
        <el-table-column sortable label="其他备注" align="center" prop="remark" show-overflow-tooltip/>
<!--        <el-table-column label="操作" align="center" class-name="small-padding fixed-width">-->
<!--          <template slot-scope="scope">-->
<!--            <el-button size="mini" type="text" icon="el-icon-document" @click="handleQualityTest(scope.row)">质量检验</el-button>-->
<!--          </template>-->
<!--        </el-table-column>-->
      </el-table>
      <factory-test-quality-goods ref="qualityTesting" @ok="getList"> </factory-test-quality-goods>
      <factory-test-quality-all-ruku ref="qualityTestingAllRuku" @ok="getList"> </factory-test-quality-all-ruku>
      <pagination v-show="total>0" :total="total" :page.sync="queryParams.pageNum"
                  :limit.sync="queryParams.pageSize" @pagination="getList"/>
    </div>
</template>

<script>
  import {deleteAction, getAction} from '@/api/manage'
  import FactoryTestQualityGoods from "@/views/develop/factory/factoryTestQuality/FactoryTestQualityGoods.vue";
  import ModifyRemarkForm from "@/views/develop/projectBaseInfo/module/ModifyRemarkForm";
  import BohuiRemarkForm from "@/views/develop/projectBaseInfo/module/BohuiRemarkForm";
  import FactoryTestQualityAllRuku from "@/views/develop/factory/factoryTestQuality/FactoryTestQualityRuku.vue";

  export default {
    name: "LvQitaRukuOtherList",
    dicts: ['isdo','goods_type','churuku_type','churuku_type'],
    components: {
      FactoryTestQualityGoods,
      ModifyRemarkForm,
      BohuiRemarkForm,
      FactoryTestQualityAllRuku
    },
    data() {
      return {
        dateRange: [],
        // 遮罩层
        loading: true,
        activeName: "first",
        // 弹出层标题
        title: "",
        // 是否显示弹出层
        open: false,
        // 表单参数
        form: {},
        // 选中数组
        ids: [],
        // 非单个禁用
        single: true,
        // 非多个禁用
        multiple: true,
        // 显示搜索条件
        showSearch: true,
        // 总条数
        total: 0,
        // 采购单表格数据
        dataList: [],
        // 查询参数
        queryParams: {
          pageNum: 1,
          pageSize: 10,
          params:{},
          sourceList: null,
          nos: null,
          projectId: null,
          projectNo: null,
          code: null,
          customerName: null,
          saleName: null,
          isZhijian: null,
          parentId: null,
          orderByColumn: "create_time",
          isAsc: "desc",
          isdo:'0',
        },
        url: {
          list: '/lvRukumingxi/lvRukumingxi/list',
          ruku: '/lvRukumingxi/lvRukumingxi/ruku/',
        },
        tableMaxHeight: window.innerHeight - 320,
      };
    },
    created() {
       this.queryParams.source = this.$route.query.source;
      this.getList();
      window.addEventListener('resize', this.getTableHeight);
    },
    methods: {
      /** 检验批次 */
      handleQualityTest(row) {
        this.$refs.qualityTestingAllRuku.showByRukuDetail(row);
      },

      showOtherDetailList(row) {
        this.open = true;
        this.title = "出库明细";
        this.queryParams.parentId=row.id;
        this.getList();
      },



      /** 查询采购单列表 */
      getList() {
        this.loading = true;
        this.addDateRange(this.queryParams, this.dateRange,"rukudate")
        getAction(this.url.list, this.queryParams).then(response => {
          this.dataList = response.rows;
          this.total = response.total;
          this.loading = false;
        });
      },
      getTableHeight() {
        this.tableHeight = window.innerHeight - 320
      },
      /** 搜索按钮操作 */
      handleQuery() {
        this.queryParams.pageNum = 1;
        this.getList();
      },
       /** 排序触发事件 */
      handleSortChange(column, prop, order) {
        this.queryParams.orderByColumn = column.prop;
        this.queryParams.isAsc = column.order;
        this.handleQuery();
      },
      /** 重置按钮操作 */
      resetQuery() {
        this.dateRange = []
          this.resetForm("queryForm");
          this.handleQuery();

      },
      // 多选框选中数据
      handleSelectionChange(selection) {
        this.ids = selection.map(item => item.id)
        this.single = selection.length !== 1
        this.multiple = !selection.length
      },
      /** 修改按钮操作 */
      handleUpdate(row) {
        this.$refs.form.handleUpdate(row);
      },
      modifyRemark(row){
        this.$refs.modifyRemarkForm.show(row);
      },
      bohui(row){
        this.$refs.bohuiRemarkForm.show(row);
      },

      qualityTesting(row){
        this.$refs.qualityTesting.showByRukuDetail(row);
      }

    }
  };
</script>
